package com.ibm.law.ui.system.setup;

import java.util.List;

import org.eclipse.nebula.widgets.grid.Grid;
import org.eclipse.nebula.widgets.grid.GridColumn;
import org.eclipse.nebula.widgets.grid.GridColumnGroup;
import org.eclipse.nebula.widgets.grid.GridItem;
import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.Composite;

import com.ibm.law.domain.Category;
import com.ibm.law.domain.ChargeItem;
import com.ibm.law.service.system.ChargeItemService;

public class ChargeItemTable extends Grid {
	private ChargeItemService chargeItemService=new ChargeItemService();
	/**
	 * Create the composite.
	 * 
	 * @param parent
	 * @param style
	 */
	public ChargeItemTable(Composite parent, int style,Category category) {
		super(parent, style);

//		setLayout(new FillLayout());
	    Grid grid = this;
		grid.setHeaderVisible(true);
		GridColumn column = new GridColumn(grid, SWT.NONE);
		column.setText("收费项目");
		column.setWidth(70);
		
		GridColumn gridColumn = new GridColumn(grid, SWT.NONE);
		gridColumn.setText("单位");
		gridColumn.setWidth(70);
		
		GridColumn gridColumn_1 = new GridColumn(grid, SWT.NONE);
		gridColumn_1.setText("基准价（元）");
		gridColumn_1.setWidth(70);
		
		GridColumn gridColumn_2 = new GridColumn(grid, SWT.NONE);
		gridColumn_2.setText("标准收费（元）");
		gridColumn_2.setWidth(70);
		GridColumnGroup columnGroup = new GridColumnGroup(grid, SWT.NONE);
		columnGroup.setText("绩效津贴");
		GridColumn column2 = new GridColumn(columnGroup, SWT.NONE);
		column2.setText("第一鉴定人");
		column2.setWidth(60);
		
		GridColumn gridColumn_5 = new GridColumn(columnGroup, SWT.NONE);
		gridColumn_5.setText("%/￥");
		gridColumn_5.setWidth(70);
		GridColumn column3 = new GridColumn(columnGroup, SWT.NONE);
		column3.setText("第二鉴定人");
		column3.setWidth(60);
		
		GridColumn gridColumn_7 = new GridColumn(columnGroup, SWT.NONE);
		gridColumn_7.setText("%/￥");
		gridColumn_7.setWidth(70);
		
		GridColumn gridColumn_13 = new GridColumn(columnGroup, SWT.NONE);
		gridColumn_13.setText("第三鉴定人");
		gridColumn_13.setWidth(70);
		
		GridColumn gridColumn_12 = new GridColumn(columnGroup, SWT.NONE);
		gridColumn_12.setText("%/￥");
		gridColumn_12.setWidth(70);
		
		GridColumn gridColumn_11 = new GridColumn(columnGroup, SWT.NONE);
		gridColumn_11.setText("复核人");
		gridColumn_11.setWidth(70);
		
		GridColumn gridColumn_10 = new GridColumn(columnGroup, SWT.NONE);
		gridColumn_10.setText("%/￥");
		gridColumn_10.setWidth(70);
		
		GridColumn gridColumn_9 = new GridColumn(columnGroup, SWT.NONE);
		gridColumn_9.setText("签发人");
		gridColumn_9.setWidth(70);
		
		GridColumn gridColumn_8 = new GridColumn(columnGroup, SWT.NONE);
		gridColumn_8.setText("%/￥");
		gridColumn_8.setWidth(70);
		
		GridColumn gridColumn_6 = new GridColumn(columnGroup, SWT.NONE);
		gridColumn_6.setText("助理");
		gridColumn_6.setWidth(70);
		
		GridColumn gridColumn_3 = new GridColumn(columnGroup, SWT.NONE);
		gridColumn_3.setText("%/￥");
		gridColumn_3.setWidth(70);
		
		GridColumn gridColumn_4 = new GridColumn(columnGroup, SWT.NONE);
		gridColumn_4.setText("文书编辑");
		gridColumn_4.setWidth(70);
		
		GridColumn gridColumn_14 = new GridColumn(columnGroup, SWT.NONE);
		gridColumn_14.setText("%/￥");
		gridColumn_14.setWidth(70);
		
		GridColumn column1 = new GridColumn(grid, SWT.NONE);
		column1.setText("备注");
		column1.setWidth(70);
		updateData(chargeItemService.findByCategory(category));
		

	}
	public void updateData(List<ChargeItem> chargeItems){
		this.removeAll();
		for(ChargeItem chargeItem:chargeItems){
			
			GridItem item = new GridItem(this, SWT.NONE);
			item.setData(chargeItem);
			item.setText(chargeItem.getName()+"");
			item.setText(1,chargeItem.getUnit()+"");
			item.setText(2,chargeItem.getBaseFee()+"");
			item.setText(3,chargeItem.getStandardFee()+"");
			item.setText(4,chargeItem.getAppraiser1Fee()+"");
			item.setText(5,chargeItem.getAppraiser1Type()+"");
			item.setText(6,chargeItem.getAppraiser2Fee()+"");
			item.setText(7,chargeItem.getAppraiser2Type()+"");
			item.setText(8,chargeItem.getAppraiser3Fee()+"");
			item.setText(9,chargeItem.getAppraiser3Type()+"");
			item.setText(10,chargeItem.getReviwerFee()+"");
			item.setText(11,chargeItem.getReviwerType()+"");
			item.setText(12,chargeItem.getSignerFee()+"");
			item.setText(13,chargeItem.getSignerType()+"");
			item.setText(14,chargeItem.getAssistantFee()+"");
			item.setText(15,chargeItem.getAssistantType()+"");
			item.setText(16,chargeItem.getEditorFee()+"");
			item.setText(17,chargeItem.getEditorType()+"");
			item.setText(18,chargeItem.getComment()+"");
		}
	}
	@Override
	protected void checkSubclass() {
		// Disable the check that prevents subclassing of SWT components
	}
}
